// Include files.
#include <vector>
#include "../SystematicRobot.hpp"
#include "ServiceSelectorService.hpp"

using namespace std;

/**
 *  Constructor for ServiceSelectorService.
 * 	
 * 	@param upInput Input for selecting up the list.  User is still reposible for deletion of parameter.
 * 	@param downInput Input for selecting down the list.  User is still reposible for deletion of parameter.
 *  @param valueOutput Value output for outputing the name of the selected Service.
 */
ServiceSelectorService::ServiceSelectorService(HumanDigitalInput &upInput, HumanDigitalInput &downInput, ValueOutput<std::string> &valueOutput) :
	SelectorService<Item>(upInput, downInput, valueOutput)
{
}

/**
 *  Constructor for ServiceSelectorService.
 * 	
 * 	@param driverStationIo Driver station IO.  User is still reposible for deletion of parameter.
 *  @param buttonUp Channel number for button for selecting up the list.
 *  @param buttonDown Channel number for button for selecting down the list.
 *  @param valueOutput Value output for outputing the name of the Service controller.
 */
ServiceSelectorService::ServiceSelectorService(DriverStationEnhancedIO &driverStationIo, UINT32 buttonUp, UINT32 buttonDown, ValueOutput<std::string> &valueOutput) :
	SelectorService<Item>(driverStationIo, buttonUp, buttonDown, valueOutput)
{
}

/**
 *  Destructor for ServiceSelectorService.
 */
ServiceSelectorService::~ServiceSelectorService()
{
}

/**
 *  Handle the Service getting added.
 * 	
 * 	@param service The added service.
 */
void ServiceSelectorService::HandleItemAdded(Service *service)
{
	AddSubservice(*service);
}

/**
 *  Handle the Service getting selected.
 * 	
 * 	@param service The selected service.
 */
void ServiceSelectorService::HandleItemSelectedImpl(Service *service)
{
	service->Start();
}

/**
 *  Handle the Service getting unselected.
 * 	
 * 	@param service The unselected service.
 */
void ServiceSelectorService::HandleItemUnselectedImpl(Service *service)
{
	service->Stop();
}
